package com.first.nell.loan

import android.annotation.SuppressLint
import android.view.View
import androidx.lifecycle.ViewModel
import androidx.navigation.findNavController
import com.first.nell.R
import com.first.nell.base.BaseActivity
import com.first.nell.databinding.ActivityFirstNellLoanLoaningBinding
import com.first.nell.enums.PageTagEnum
import com.first.nell.me.MeLoanLoaningFragmentDirections
import com.first.nell.statement.StatementLoanLoaningFragmentDirections

/** 放款中 */
@SuppressLint("CustomSplashScreen")
class LoanLoaningActivity : BaseActivity() {

    private lateinit var mActivityBinding: ActivityFirstNellLoanLoaningBinding

    override fun onFirstNellBindingFirstNellViewFirstNellModel(): List<ViewModel>? {
        val list = mutableListOf<ViewModel>()
        return list
    }

    override fun onFirstNellBindingFirstNellViewFirstNellTag(): String {
        return PageTagEnum.loaning.name.uppercase()
    }

    override fun onFirstNellBindingFirstNellContentFirstNellView(): View {
        mActivityBinding = ActivityFirstNellLoanLoaningBinding.inflate(layoutInflater)
        return mActivityBinding.root
    }

    override fun onFirstNellContentFirstNellViewFirstNellBinded() {
        try {
            mActivityBinding.bottomTabBarLoanLoaning.setFirstNellOnFirstNellActionFirstNellClickFirstNellListener {
                when (it) {
                    0 -> {
                        if (findNavController(R.id.navLoanLoaningFragment).currentDestination?.id == R.id.loan_loaning_me) {
                            findNavController(R.id.navLoanLoaningFragment)
                                .navigate(MeLoanLoaningFragmentDirections.toLoanLoaningHome())

                        } else if (findNavController(R.id.navLoanLoaningFragment).currentDestination?.id == R.id.loan_loaning_statement) {
                            findNavController(R.id.navLoanLoaningFragment)
                                .navigate(StatementLoanLoaningFragmentDirections.toLoanLoaningHome())
                        }
                    }
                    1 -> {
                        if (findNavController(R.id.navLoanLoaningFragment).currentDestination?.id == R.id.loan_loaning_home) {
                            findNavController(R.id.navLoanLoaningFragment)
                                .navigate(LoanLoaningFragmentDirections.toLoanLoaningStatement())

                        } else if (findNavController(R.id.navLoanLoaningFragment).currentDestination?.id == R.id.loan_loaning_me) {
                            findNavController(R.id.navLoanLoaningFragment)
                                .navigate(MeLoanLoaningFragmentDirections.toLoanLoaningStatement())
                        }
                    }
                    2 -> {
                        if (findNavController(R.id.navLoanLoaningFragment).currentDestination?.id == R.id.loan_loaning_home) {
                            findNavController(R.id.navLoanLoaningFragment)
                                .navigate(LoanLoaningFragmentDirections.toLoanLoaningMe())

                        } else if (findNavController(R.id.navLoanLoaningFragment).currentDestination?.id == R.id.loan_loaning_statement) {
                            findNavController(R.id.navLoanLoaningFragment)
                                .navigate(StatementLoanLoaningFragmentDirections.toLoanLoaningMe())
                        }
                    }
                    else -> {

                    }
                }
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

}